package mn.slide.petrovis.connection;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.List;
import mn.slide.petrovis.model.Aimag;
import mn.slide.petrovis.model.Province;
import org.apache.http.client.ClientProtocolException;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

import android.content.Context;

public class HttpConnector extends AbstractHttpConnector
{
	public final static String	BRANCH_UB	= "http://www.petrovis.mn/flash/ub_mn.xml";

	@Override
	public List<Aimag> getAimag(Context context,String url )
	{
		List<Aimag> aimags = null;
		try
		{
			String data = httpGET(url);
			Reader reader = new StringReader(data);
			Serializer serializer = new Persister();
			Province province = serializer.read(Province.class, reader, false);
			aimags = province.aimags;

		}
		catch (ClientProtocolException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return aimags;
	}



}
